#include <unistd.h>
#include <stdio.h>
#include <sys/wait.h>

int main(int argc, char const *argv[])
{
    int num=100;


   int pid= fork();

   if(pid==0)
   {    
        num+=80;
         sleep(1000);
        printf("child process num=%d\n",num);
        printf("child process pid=%d , parent = %d\n",pid,getppid());
       
   }
   else
   {    sleep(1);
        printf("parent process num=%d\n",num);
        printf("parent process pid=%d , child = %d ,parent=%d\n",getpid(),pid,getppid());
         // waitpid(pid,NULL,0);
        while(1)
        {   
            int over_status=0;
            int pid= waitpid(pid,&over_status,WNOHANG);
            printf("pid=%d, over_status=%d\n",pid,over_status );
            sleep(1);
        }

        printf("parent process over \n" );
   }
 

    return 0;
}
